require.config({
    baseUrl:"./modules",
    paths:{
        jq: "../libs/jquery",
        "cookie": "../libs/jquery.cookie",
        page:'../libs/jquery.pagination'
    },
    shim:{
        cookie:{
            deps:["jq"]
        },
        page:{
            deps:["jq"]
        }
       
    }
})

require(['cookie','page','getGoods','listRender','listIndex','listHot','guessLike',"setLocal"],(_cookie,_page,gg,lr,li,lh,gl,sl)=>{
    console.log('sss')
    const serUrl ='http:/localhost:3000/api';

    
  
//    const s= $('.head').load('public-page/head.html#sou')

// const n = location.search
const d = decodeURI(location.search.split('?')[1])
console.log(d)

    console.log(String.fromCharCode(25628))
    gg(serUrl,'getGoods', function(res){ 
        $('.head').load('public-page/head.html',function(){
            $(document).keydown(function(){
                if(event.keyCode===13){
                    console.log($('#sousuo').val(),1234)
                    lr($('#sousuo').val(),$('#sou'), $(".shop-list"),res)
                    const a = document.querySelectorAll('.shop-list input')
                    const jia = document.querySelectorAll('.shop-list #jia')
                    const jian = document.querySelectorAll('.shop-list #jian')
                    li(a,jia,jian)
                }
            })
            // $('#sou').on('click',function(){
            //     console.log($('#sousuo').val(),1234)
            //     lr($('#sousuo').val(),$('#sou'), $(".shop-list"),res)
            //     const a = document.querySelectorAll('.shop-list input')
            //     const jia = document.querySelectorAll('.shop-list #jia')
            //     const jian = document.querySelectorAll('.shop-list #jian')
            //     li(a,jia,jian)
            // })
            // lr('',6,$(".shop-list"),res)
            if(d=='undefined'){
                console.log('所有')
                lr('',6,$(".shop-list"),res)
            }else{
                console.log('搜索')
                lr(d,6,$(".shop-list"),res)
            }
            const a = document.querySelectorAll('.shop-list input')
            const jia = document.querySelectorAll('.shop-list #jia')
            const jian = document.querySelectorAll('.shop-list #jian')
            li(a,jia,jian)
            // 价格排序
            
            const or= document.querySelectorAll('.rank li');
            or[2].onclick=function(){
                console.log(5678899999999999)
                let arr =[...res];
                console.log(arr,000000000000)
                arr.sort((a,b)=>a.price-b.price);
                lr('',6,$(".shop-list"),arr)
                const a = document.querySelectorAll('.shop-list input')
                const jia = document.querySelectorAll('.shop-list #jia')
                const jian = document.querySelectorAll('.shop-list #jian')
                li(a,jia,jian)
            }
            let index=0;
            // for (let i =0;i<or.length;i++){
            //     or[i].xuhao=i
            //     or[i].onclick=function(){
            //         or[index].style.color='#666';
            //         or[index].style.background='#fff'
            //         or[i].style.color='#fff';
            //         or[i].style.background='red'
            //         index=this.xuhao
            //     }
            // }
          
        })
    $('.bottom').load('public-page/bottom.html')
    lh($('.tjhot-shoplist'),2,res)
     gl($('.like-list'),res)
    $('.change').on('click',function(){
        console.log(7878)
        gl($('.like-list'),res)
    })
    })
	console.log("陈峰")
	//设置本地存储
	$("body").on("click",".addlocal",function(){
		const num=$(this).parent().children(".listnum").val()-0;
		const id=($(this).parent().attr("dataid"));
		const price=$(this).parent().prev().prev().children().children(".nowprice").text();
		sl(id,price,num)
	})
    
   
})
